Skip to content

Refactor (script/upgrade-opentui.ts): Function with many returns - #48

Open
NancyAanchal wants to merge 2 commits into
CMU-17313Q:mainfrom
NancyAanchal:refactor-opentui-setversion
Open

Refactor (script/upgrade-opentui.ts): Function with many returns#48
NancyAanchal wants to merge 2 commits into
CMU-17313Q:mainfrom
NancyAanchal:refactor-opentui-setversion

Conversation

@NancyAanchal

@NancyAanchal NancyAanchal commented Sep 3, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #33

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

->Qlty flagged setVersion in script/upgrade-opentui.ts for "many returns," 7 return statements. Collapsed the 7 returns into a single lookup/array + .find() pattern that picks a prefix, then one final return. Moreover, the function was using some global variables, changed it to accomodate those in the parameters. Also made the function exportable for tests.

Please provide a description of the issue, the changes you made to fix it, and why they work. It is expected that you understand why your changes work and if you do not understand why at least say as much so a maintainer knows how much to value the PR.

If you paste a large clearly AI generated description here your PR may be IGNORED or CLOSED!

How did you verify your code works?

-Ran qlty smells --no-snippets script/upgrade-opentui.ts before and after — "many returns" smell disappeared, file complexity dropped from 63 to 55
-Wrote script/upgrade-opentui.test.ts with 8 tests covering every branch of setVersion
-Ran bun test upgrade-opentui.test.ts from script/ and all 8 pass
-Ran coverage and setVersion itself fully exercised; only uncovered lines are the untouched CLI logic
-Added a CI step in test.yml so these tests actually run on this PR

Screenshots / recordings

image

If this is a UI change, please include a screenshot or recording.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

If you do not follow this template your PR will be automatically rejected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor (script/upgrade-opentui.ts:45): Function with many returns (count = 7)

1 participant